﻿-- =============================================
-- Author:		Andreas Könighofer (IT-eXperience)
-- Create date: 15.01.2009
-- Description:	Reads all customers that match with the given parameters
-- =============================================
CREATE PROCEDURE [dbo].[ReadCustomer]
	-- Add the parameters for the stored procedure here
	@CustomerID INT = NULL 
	, @CustomerName NVARCHAR(100) = NULL
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT
	CustomerID,
	Location.LocationName,
	CustomerName
	FROM Customer
	, Location
	WHERE ((@CustomerID IS NULL) OR (CustomerID = @CustomerID))
	AND ((@CustomerName IS NULL) OR (CustomerName LIKE '%'+@CustomerName+'%'))
END

---- end script ReadCustomer stored procedure ----

---- start script ReadLocation stored procedure ----

